package cn.kgc.itrip.controller;

import cn.kgc.itrip.beans.dto.Dto;
import cn.kgc.itrip.beans.pojo.ItripUser;
import cn.kgc.itrip.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2018/11/23.
 */
@RestController
public class RegeditController {
    @Resource
    private UserService userService;

    @RequestMapping(consumes = "application/json",value="mailRegedit" ,method = RequestMethod.POST)
    public Dto emailRege(String name, String password, String nickname){
        ItripUser user=new ItripUser();
        user.setUserCode(name);
        user.setUserPassword(password);
        user.setUserName(nickname);
        return userService.emailRegister(user);
    }

    @RequestMapping(consumes = "application/json",value="activeMail" ,method = RequestMethod.POST)
    public Dto activeMail(String name, String code){
        return userService.validator(name,code);
    }

    @RequestMapping(consumes = "application/json",value="resetPhoneCode" ,method = RequestMethod.POST)
    public Dto resetPhoneCode(String phone){
        return userService.resetPhoneCoded(phone);
    }

    @RequestMapping(consumes = "application/json",value="phoneRegedit" ,method = RequestMethod.POST)
    public Dto phoneRegedit(String phone, String password, String nickname){
        ItripUser user=new ItripUser();
        user.setUserCode(phone);
        user.setUserPassword(password);
        user.setUserName(nickname);
        return userService.phoneRegister(user);
    }

}
